package com.lsmo.android.carfans;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.ImageView;

import com.lsmo.android.util.DisplayMetricsData;

/**
 * 功能说明：程序启动时欢迎页面
 * @author SYX
 *
 */
public class HomeLoadingActivity extends Activity{
	// 自动等待5秒
	private static final int DELAY_TIME_MILLI_SEC = 1000;
	private Context mContext;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		DisplayMetricsData.displayMetrics(dm);
		
		//程序启动欢迎页面
		ImageView imageView = new ImageView(this);
		imageView.setImageResource(R.drawable.ad);
		setContentView(imageView);
		
		//加载loading启动线程
		new Thread(new loadingThread()).start();
	}
	
	class loadingThread extends Thread {
		@Override
		public void run() {
			try {
				Thread.sleep(DELAY_TIME_MILLI_SEC);
				
				closeLoadingWindow();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			super.run();
		}
	}
	
	/** 关闭窗口 **/
	public void closeLoadingWindow() {
		Intent intent = new Intent(this, MainActivity.class);
		this.startActivity(intent);
		finish();
	}
	
	
	
}
